fix: implement save mutation in opportunity details edit form#409
fix: implement save mutation in opportunity details edit form#409Cy-fox wants to merge 2 commits intoneed4deed-org:developfrom
Conversation
Closes need4deed-org#393 Appointment times were stored as UTC strings by the API but displayed without timezone conversion, causing times to appear 2 hours early for users in CEST (UTC+2). Changes: - parseTime in AccompanyingDetails helpers now converts UTC HH:mm strings to local time using setUTCHours before extracting via toTimeString - formatAccompanyingDate in OpportunityCard.helpers now formats the date with date-fns and applies the same UTC-to-local conversion for the time
Closes need4deed-org#401 The save button in OpportunityDetails had a placeholder onSubmit that only closed the form without persisting any changes. Added the PATCH mutation and conversion helpers to send form values to the API. Changes: - Add useUpdateOpportunityDetails hook that PATCHes the opportunity endpoint - Implement onSubmit in OpportunityDetailsEdit to call the mutation with description, numberVolunteers, languages, activities, skills and schedule - Add toLangOptionItems and toOptionItems helpers to convert form state to the OptionItem shape expected by ApiOpportunityPatch - Add saveSuccess i18n keys to EN and DE translation files
nadavosa
left a comment
There was a problem hiding this comment.
PR #409 Review: Implement save mutation in opportunity details edit form
Critical: eventDate/eventTime are never sent to the API for event-type opportunities
OpportunityDetailsEdit.tsx onSubmit: When isEventType is true, the form shows eventDate and eventTime fields, but the mutation payload only includes description, numberVolunteers, languages, activities, skills, and schedule. Event date/time are collected from the user and then silently discarded.
High: toLangOptionItems matches by translated display name, not by canonical ID
toLangOptionItems compares field.value (a translated language name in the user's locale) against apiLanguage.title (the English/canonical name). In German locale, "Arabisch" won't match "Arabic" — the language gets silently dropped from the payload. The lookup should use language id throughout, not the string title.
Medium: parseTime timezone bug propagated to two new locations
d.setUTCHours(h, m) followed by d.toTimeString().slice(0, 5) reads UTC-set hours in local time — in UTC+2 this displays 2 hours ahead. This was a pre-existing bug, but the PR copies it into formatAccompanyingDate in OpportunityCard.helpers.tsx. Should use String(d.getUTCHours()).padStart(2,'0') + ":" + String(d.getUTCMinutes()).padStart(2,'0') instead.
Low: formatAccompanyingDate added to OpportunityCard.helpers.tsx but not used
The new function is added but no call site in the diff uses it. If speculative, defer to the PR that actually needs it.
Closes #401
The save button in OpportunityDetails had a placeholder onSubmit that only closed the form without persisting any changes. Added the PATCH mutation and conversion helpers to send form values to the API.
Changes:
useUpdateOpportunityDetailshook that PATCHes the opportunity endpointOpportunityDetailsEditto call the mutation with description,numberVolunteers, languages, activities, skills and scheduletoLangOptionItemsandtoOptionItemshelpers to convert form state to theOptionItemshape expected byApiOpportunityPatchsaveSuccessi18n keys to EN and DE translation files